/*   1:    */ package com.atomikos.icatch.imp;
/*   2:    */ 
/*   3:    */ import com.atomikos.icatch.HeurCommitException;
/*   4:    */ import com.atomikos.icatch.HeurHazardException;
/*   5:    */ import com.atomikos.icatch.HeurMixedException;
/*   6:    */ import com.atomikos.icatch.HeurRollbackException;
/*   7:    */ import com.atomikos.icatch.HeuristicMessage;
/*   8:    */ import com.atomikos.icatch.Participant;
/*   9:    */ import com.atomikos.icatch.RollbackException;
/*  10:    */ import com.atomikos.icatch.SysException;
/*  11:    */ import com.atomikos.icatch.TransactionService;
/*  12:    */ import com.atomikos.icatch.system.Configuration;
/*  13:    */ import java.util.Dictionary;
/*  14:    */ 
/*  15:    */ public class SubTransactionCoordinatorParticipant
/*  16:    */   implements Participant
/*  17:    */ {
/*  18:    */   private static final long serialVersionUID = -321213151844934630L;
/*  19:    */   private transient Participant subordinateCoordinator;
/*  20:    */   private String subordinateId;
/*  21:    */   private HeuristicMessage[] msgs;
/*  22:    */   private boolean prepareCalled;
/*  23:    */   
/*  24:    */   public SubTransactionCoordinatorParticipant(CoordinatorImp subordinateCoordinator)
/*  25:    */   {
/*  26: 70 */     this.subordinateCoordinator = subordinateCoordinator;
/*  27: 71 */     this.subordinateId = subordinateCoordinator.getCoordinatorId();
/*  28: 72 */     this.msgs = subordinateCoordinator.getHeuristicMessages();
/*  29: 73 */     this.prepareCalled = false;
/*  30:    */   }
/*  31:    */   
/*  32:    */   public boolean recover()
/*  33:    */     throws SysException
/*  34:    */   {
/*  35: 81 */     TransactionService ts = Configuration.getTransactionService();
/*  36: 82 */     this.subordinateCoordinator = ts.getParticipant(this.subordinateId);
/*  37: 83 */     return this.subordinateCoordinator != null;
/*  38:    */   }
/*  39:    */   
/*  40:    */   public String getURI()
/*  41:    */   {
/*  42: 91 */     return this.subordinateId;
/*  43:    */   }
/*  44:    */   
/*  45:    */   public void setCascadeList(Dictionary allParticipants)
/*  46:    */     throws SysException
/*  47:    */   {
/*  48:103 */     this.subordinateCoordinator.setCascadeList(allParticipants);
/*  49:    */   }
/*  50:    */   
/*  51:    */   public void setGlobalSiblingCount(int count)
/*  52:    */   {
/*  53:114 */     this.subordinateCoordinator.setGlobalSiblingCount(count);
/*  54:    */   }
/*  55:    */   
/*  56:    */   public int prepare()
/*  57:    */     throws RollbackException, HeurHazardException, HeurMixedException, SysException
/*  58:    */   {
/*  59:124 */     this.prepareCalled = true;
/*  60:125 */     return this.subordinateCoordinator.prepare();
/*  61:    */   }
/*  62:    */   
/*  63:    */   public HeuristicMessage[] commit(boolean onePhase)
/*  64:    */     throws HeurRollbackException, HeurHazardException, HeurMixedException, RollbackException, SysException
/*  65:    */   {
/*  66:135 */     HeuristicMessage[] ret = getHeuristicMessages();
/*  67:136 */     if (this.subordinateCoordinator != null)
/*  68:    */     {
/*  69:137 */       this.subordinateCoordinator.commit(onePhase);
/*  70:    */     }
/*  71:    */     else
/*  72:    */     {
/*  73:138 */       if (this.prepareCalled) {
/*  74:139 */         throw new HeurHazardException(ret);
/*  75:    */       }
/*  76:143 */       throw new RollbackException();
/*  77:    */     }
/*  78:145 */     return ret;
/*  79:    */   }
/*  80:    */   
/*  81:    */   public HeuristicMessage[] rollback()
/*  82:    */     throws HeurCommitException, HeurMixedException, HeurHazardException, SysException
/*  83:    */   {
/*  84:154 */     HeuristicMessage[] ret = getHeuristicMessages();
/*  85:155 */     if (this.subordinateCoordinator != null) {
/*  86:156 */       this.subordinateCoordinator.rollback();
/*  87:157 */     } else if (this.prepareCalled) {
/*  88:159 */       throw new HeurHazardException(ret);
/*  89:    */     }
/*  90:163 */     return ret;
/*  91:    */   }
/*  92:    */   
/*  93:    */   public void forget()
/*  94:    */   {
/*  95:171 */     if (this.subordinateCoordinator != null) {
/*  96:172 */       this.subordinateCoordinator.forget();
/*  97:    */     }
/*  98:    */   }
/*  99:    */   
/* 100:    */   public HeuristicMessage[] getHeuristicMessages()
/* 101:    */   {
/* 102:181 */     if (this.subordinateCoordinator != null) {
/* 103:182 */       this.msgs = this.subordinateCoordinator.getHeuristicMessages();
/* 104:    */     }
/* 105:184 */     return this.msgs;
/* 106:    */   }
/* 107:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions\3.7.0\transactions-3.7.0.jar
 * Qualified Name:     com.atomikos.icatch.imp.SubTransactionCoordinatorParticipant
 * JD-Core Version:    0.7.0.1
 */